# -*- coding: utf-8 -*-
# @Time    : 2024/11/29 下午8:30
# @Author  : wjx
# @Email   : kanxinxin@163.com
# @File    : create_works_page.py
# @Software: PyCharm
from appium.webdriver.common.appiumby import AppiumBy as By
from pages.base_page import BasePage


class CreateWorksPage(BasePage):
    # 定位器
    # 分享下厨心得
    content_locator = (By.XPATH, '//android.widget.EditText[@resource-id="com.xiachufang:id/dish_desc"]')
    # 发布
    publish_locator = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().className("android.widget.LinearLayout").instance(4)')
    # 取消
    dismiss_locator = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().resourceId("com.xiachufang:id/img_container")')
    # 取消编辑的提示
    abandon_tips_locator = (By.ANDROID_UIAUTOMATOR,'new UiSelector().resourceId("android:id/button1")')
    # 关闭
    close_locator = (By.XPATH, '//android.widget.TextView[@resource-id="com.xiachufang:id/navigation_right_btn"]')

    def input_content(self,content):
        """
        输入分享下厨心得
        :param content:
        :return:
        """
        content_element = self.find_element(self.content_locator)
        content_element.click()
        content_element.send_keys(content)

    def click_publish(self):
        """
        点击发布
        :return: None
        """
        self.find_element(self.publish_locator).click()

    def click_dismiss(self):
        """
        点击×
        :return: None
        """
        self.find_element(self.dismiss_locator).click()

    def click_abandon_tips(self):
        """
        提示框点击放弃
        :return:None
        """
        self.find_element(self.abandon_tips_locator).click()

    def click_close(self):
        """
        点击关闭
        :return:None
        """
        self.find_element(self.close_locator).click()
